import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:xin_he/utils/xin_he_count_down_widget.dart';
import 'package:xin_he/utils/xin_he_image.dart';

import '../../../utils/xh_styles.dart';
import '../../../utils/xin_he_input_widget.dart';
import 'xin_he_forget_pwd_logic.dart';

class XinHeForgetPwdPage extends StatelessWidget {
  XinHeForgetPwdPage({Key? key}) : super(key: key);

  final logic = Get.put(XinHeForgetPwdLogic());
  final state = Get.find<XinHeForgetPwdLogic>().state;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        leading: IconButton(
            onPressed: (){
              Get.back();
            },
            icon: Container(
              padding: EdgeInsets.only(left: 7),
              alignment: Alignment.centerLeft,
              child: const XinHeAssetImage(
                'assets/images/home/app_back_3.png',
                width: 9.5,
                height: 17,
                fit: BoxFit.cover,),
            )
        ),
        title: const Text('修改密码',style: TextStyle(color: Colors.black , fontSize: 18,fontWeight: FontWeight.w600),),
        backgroundColor: Colors.white,
        shadowColor: Colors.transparent,
      ) ,
      body: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [

          ///  手机号
          Container(
            height: 55,
            padding: EdgeInsets.symmetric(horizontal: 15),
            color: Colors.white,
            child: XinHeInputWidget(
              '手机号',
              '请输入您的手机号',
              logic.onPhoneChange,
              maxInputLength: 11,
              keyboardType: TextInputType.phone,
              isHiddenLine: false,
              isObscure: false,),

          ),

          Container(
            color: Colors.white,
            height: 55,
            margin: const EdgeInsets.symmetric(horizontal:15).copyWith(top: 0),
            width: Get.width,
            child: Row(
              children: [

                Expanded(child: XinHeInputWidget('验证码', '请输入验证码', (value){},keyboardType: TextInputType.number,maxInputLength: 6,isHiddenLine: true,)),

                XinHeTimerCountDownWidget(
                  norText: '发送验证码',
                  themeColor: XinHeColor('#10C9C9'),
                  onStarEvent: () => logic.clickGetCode(),
                  // maxSec : 120,180
                )
              ],
            ),
          ),

          Container(
            height: 1,
            margin: EdgeInsets.symmetric(horizontal: 15),
            color: XinHeColor('#E3E3E3'),
          ),


          /// 新密码输入框
          Container(
            height: 55,
            color: Colors.white,
            margin: const EdgeInsets.symmetric(horizontal: 15, ),
            child:
            XinHeInputWidget(
              '新密码',
              '请输入6-16位新密码 ',
              logic.onNewPasswordChange,
              maxInputLength: 16,
              isObscure: true,),
          ),

          /// 确定密码输入框
          Container(
            height: 55,
            color: Colors.white,
            margin: const EdgeInsets.symmetric(horizontal: 15, ),
            child:
            XinHeInputWidget(
              '确认密码',
              '请确认密码',
              logic.onSurePasswordChange,
              maxInputLength: 16,
              isObscure: true,),
          ),



          // Obx(() => Container(
          //   height: state.codeSendSuccess.value==true ?21:0,
          //   margin: const EdgeInsets.only(left: 32,right: 32,top: 8),
          //   child: Text(logic.getPhoneString(),style: TextStyle(color: XinHeColor('#979FB5'),fontSize: 14),),
          // ),),

          Spacer(),
          Container(
            margin:   EdgeInsets.only(left: 15,right: 15,bottom: Get.mediaQuery.padding.bottom+25),
            height: 44,
            width: double.infinity,
            decoration: BoxDecoration(color:XinHeColor('#30E9E9'),borderRadius: const BorderRadius.all(Radius.circular(22))),
            child: OutlinedButton(

              onPressed: logic.savePassword,
              child:  const Text (
                "保存",
                style: TextStyle (fontSize: 16,color:  Colors.white, fontWeight: FontWeight.bold) ,
                strutStyle: StrutStyle(
                  fontSize: 16,
                  leading: 0,
                  height: 1.1,
                  // 1.1更居中
                  forceStrutHeight: true, // 关键属性 强制改为文字高度
                ),
              ),
            ),)



        ],
      ),
    );
  }
}
